package com.shoulei.designpattern.flyweightPattern;

import java.util.HashMap;

/**
 * @ClassName:ShapeFactory
 * @Descrition:
 * @Author:shoulei
 * @Date:2019/4/14 15:20
 * @Verson:
 */
public class ShapeFactory {
    private static final HashMap<String, Shape> circleMap = new HashMap<>();
    public static Shape getCircle(String color){
        Circle circle = (Circle) circleMap.get(color);
        if(circle == null){
            circle = new Circle(color);
            circleMap.put(color,circle);
            System.out.println("Circle circle of color :" + color);
        }
        return circle;
    }
}
